package com.javacoding.huawei;

import java.util.Scanner;

/**
 * @author BLADE
 * @description:
 * @data 2024/4/249:11
 */
public class HJ22汽水瓶 {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        while (scanner.hasNext()){
            int n=scanner.nextInt();
            if(n==0)
                break;
            int count=0;
            while (n>=3){
                count+=n/3;
                n=n/3+n%3;
                if(n==2)
                    n++;
            }
            System.out.println(count);
        }
    }
}
